<template>
    <section>
        <sy-baselist
                listUrl="server/system/Message.ashx?cmd=GetList"
                hideHeader
                hideAdd
                title="业务消息"
                hideOperate
                ref="Message"
        >
            <el-table-column >
                <template scope="scope">
                    <span class="message-dot" v-if="showDot(scope.row)"></span>
                    <a class="detail" href="javascript:;" @click="viewMessage(scope.row)">{{getFtitle(scope.row)}}{{ scope.row.FDetail }}</a>
                </template>
            </el-table-column>
            <el-table-column width="200px">
                <template scope="scope">
                    {{scope.row.FSendDate | formatDate2}}
                </template>
            </el-table-column>
        </sy-baselist>
        <applyedit ref="applyedit"></applyedit>
        <deliveryedit ref="deliveryedit"></deliveryedit>
    </section>
</template>

<script>
    import Vue from 'Vue'
    import util from '../common/util'
    import mixin from '../common/mixin'
    import applyedit from './business/Apply_Edit.vue'
    import deliveryedit from './business/Delivery_Edit.vue'
    export default {
        mixins: [mixin],
        data(){
            return {

            }
        },
        components:{
            applyedit,deliveryedit

        },
        methods:{
            getFtitle(row){
                if(row.FTitle) {
                    return "【" + row.FTitle + "】"
                }
                return ''
            },
            viewMessage(row){
                let config ={
                    apply:{
                        editVue:"applyedit",
                        getUrl:"server/business/Apply.ashx?cmd=GetOne",
                        ApproveID:1
                    },
                    delivery:{
                        editVue:"deliveryedit",
                        getUrl:"server/business/Delivery.ashx?cmd=GetOne",
                        ApproveID:2
                    }
                }
                if(config[row.FBillType] && row.FBillID)
                {
                    util.get(config[row.FBillType].getUrl,
                        {FID : row.FBillID},this.progressFn,result=>{
                            //this.createEditForm(config[row.FBillType].editVue).
                            this.$refs[config[row.FBillType].editVue]._openApprove(util.date.formatObj(result.data),config[row.FBillType].ApproveID)
                        })
                    util.post("server/system/Message.ashx?cmd=Read",{FID:row.FID},null,result=>{
                        this.$refs.Message._refrash();
                        global.bus.$emit('RefreshMsgCount')
                    })
                }
            },
            showDot(row){
                if(row.FStatus==1){
                    return false
                }
                return true
            },
            onSaveSuc:function (row) {
                this.$refs.Message._refrash();
            }
        },
        created(){

        }
    }
</script>
<style scoped>
    .detail{
        color: black;
        text-decoration:none;
    }
    .detail:hover{
        color: #13c19f;
    }
    .message-dot {
        position: absolute;
        top: 9px;
        left: 8px;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: #f33333;
        margin-top:5px;
    }
</style>